The SEHTEST Sample accompanies Chapter 3 and illustrates the use of a structured exception frame.
The sample includes one component:
To build SEHTEST.SYS, follow the general instructions for building a WDM sample. The Microsoft Visual C++ project file is named SEHTEST.DSP.
Install the SEHTEST.SYS driver. Follow the general instructions for using FastInst in Windows. The INF file is named DEVICE.INF.
Do not try to test this sample in Windows 98.
While WDM driver code is running, the FS register should always contain a special selector used for structured exception handling. There is a bug in Windows 98 that causes DriverEntry to be called with FS holding the wrong selector when you install this sample program. I'll post further information about this bug and possible workarounds on my web page when I get it.The DriverEntry routine in SEHTEST establishes a structured exception frame and calls ProbeForWrite to attempt to validate an invalid pointer. ProbeForWrite will raise an exception that SEHTEST will catch.
To verify that SEHTEST has done the right thing, you need to view the debugging output from the driver. Either run under the control of a debugger, or start DbgView (see http://www.sysinternals.com) beforehand.
Note that the SEHTEST device will show up in the Device Manager display with a yellow exclamation mark to indicate that no driver could be loaded. This is the normal result of installing this sample, because DriverEntry returns a failure code.